package com.audaque.springboot.foshanupload.web.springsecuritycas.config;

import com.audaque.springboot.foshanupload.web.springsecuritycas.handler.CasSecurityContextLogoutHandler;
import org.jasig.cas.client.session.SingleSignOutFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.web.authentication.logout.LogoutFilter;

/**
 * @author zgb
 * @desc ...
 * @date 2022-12-12 23:37:15
 */
@Configuration
public class ServiceSecurityCasLogoutFilterConfig {

    @Autowired
    private CasServerConfig casServerConfig;

    @Autowired
    private CasServiceConfig casServiceConfig;
    /**
     * 登出过滤器
     *
     * @return
     */
    @Bean
    public LogoutFilter logoutFilter() {
        String logoutRedirectPath = this.casServerConfig.getLogout() + "?service=" + this.casServiceConfig.getWebHost();
        LogoutFilter logoutFilter = new LogoutFilter(logoutRedirectPath, new CasSecurityContextLogoutHandler());
        logoutFilter.setFilterProcessesUrl(this.casServiceConfig.getLogout());
        return logoutFilter;
    }



}
